package com.church.daoimpl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.church.dao.ChildDao;
import com.church.db.Child;

public class ChildDaoImpl extends HibernateDaoSupport implements ChildDao {

	@Override
	public String add(Child child) {
		this.getHibernateTemplate().save(child);
		return "success";
	}

	@Override
	public String update(Child child) {
		this.getHibernateTemplate().update(child);
		return "success";
	}

	@Override
	public Child findById(int id) {
		List<Child> list=this.getHibernateTemplate().find("from Child where id="+id);
		if(list.size()>0)
		{
			return list.get(0);
		}
		return null;
	}

	@Override
	public List<Child> getList() {
		return this.getHibernateTemplate().find("from Child where state!=3");
	}

}
